package com.wl.myscalajob

object Job1 {
  def main(args: Array[String]): Unit = {
    //第一次买酒
    val one = 100/2
    println(s"总喝啤酒数为：${one + buyBeer(0,one,one)}")
  }

  /**
   *
   * @param sum    总共瓶数
   * @param bottle 空瓶
   * @param cap    瓶盖
   * @return
   */
  def buyBeer(sum:Int ,bottle:Int ,cap:Int): Int ={
    if(bottle < 3 && cap <5 ) return sum
    var a1 = bottle/3
    var a2 = bottle%3
    var b1 = cap/5
    var b2 = cap%5
    println(f"总数：${a1+b1+sum}，上次余留瓶子：${a1 + a2 + b1 }%02d；上次余留瓶盖：${a1 + b1 + b2}%02d")
    return buyBeer(a1+b1+sum,a1 + a2 + b1,a1 + b1 + b2)
  }
}
